import os
import yaml
from pathlib import Path
from typing import Dict, Any
from handle.handle_path import BASEDIR


def load_yaml_config():
    with open(BASEDIR + "/" + "config/config.yaml", 'r', encoding='utf-8') as file:
        result = yaml.safe_load(file)
        return result



# 加载配置
config = load_yaml_config()


class Settings:

    # 定时任务配置
    REDIS_HOST: str = os.getenv("REDIS_BASE", config["config"]["redis"]["host"])
    REDIS_PORT: int = os.getenv("REDIS_PORT", config["config"]["redis"]["port"])
    REDIS_PASSWORD: str = os.getenv("REDIS_PASSWORD", config["config"]["redis"]["password"])
    REDIS_DB: int = os.getenv("REDIS_DB", config["config"]["redis"]["db"])
    SCHEDULES: str = config["config"]["scheduler"]["crontab"]

    # 钉钉发消息
    WEBHOOK: str = config["config"]["dingtalk"]["WEBHOOK"]
    SECRET: str = config["config"]["dingtalk"]["SECRET"]


settings = Settings()